﻿package com.neriksworkshop.lib.colourLovers.core 
{
	import com.neriksworkshop.lib.colourLovers.items.IGraphicItem
	import com.neriksworkshop.lib.colourLovers.params.Params;
	import flash.display.Sprite;
	import flash.geom.Rectangle;

	
	/**
	 * ...
	 * @author Erik
	 */
	public class AbstractGraphicItem extends AbstractItem implements IGraphicItem
	{
		
		protected var _title:String;
		protected var _numViews:int;
		protected var _numVotes:int;
		protected var _numComments:int;
		protected var _numHearts:int;
		protected var _rank:int;
		protected var _dateCreated:Date;
		protected var _description:String;
		protected var _imageUrl:String;
		protected var _badgeUrl:String;
		
		protected var _sp:Sprite;
		
		
		public function AbstractGraphicItem(self:AbstractGraphicItem) 
		{
			super(this);
		}
		
		override public function buildFromData(data:*):void
		{
			super.buildFromData(data);
			_title = data.title;
			_numViews = int(data.numViews);
			_numVotes = int(data.numVotes);
			_numComments = int(data.numComments);
			_numHearts = int(data.numHearts);
			_rank = int(data.rank);
			_dateCreated = dateFromString(data.dateCreated);
			_description = data.description;
			_imageUrl = data.imageUrl;
			_badgeUrl = data.badgeUrl;
		}
		
		/*
		public  override function buildFromXML(xmlData:XML):void
		{		
			super.buildFromXML(xmlData);
			_title = xmlData.title;
			_numViews = int(xmlData.numViews);
			_numVotes = int(xmlData.numVotes);
			_numComments = int(xmlData.numComments);
			_numHearts = int(xmlData.numHearts);
			_rank = int(xmlData.rank);
			_dateCreated = dateFromString(xmlData.dateCreated);
			_description = xmlData.description;
			_imageUrl = xmlData.imageUrl;
			_badgeUrl = xmlData.badgeUrl;
		}
		
		public override function buildFromJSON(jsonData:Object):void
		{
			super.buildFromJSON(jsonData);
			_title = jsonData.title;
			_numViews = int(jsonData.numViews);
			_numVotes = int(jsonData.numVotes);
			_numComments = int(jsonData.numComments);
			_numHearts = int(jsonData.numHearts);
			_rank = int(jsonData.rank);
			_dateCreated = dateFromString(jsonData.dateCreated);
			_description = jsonData.description;
			_imageUrl = jsonData.imageUrl;
			_badgeUrl = jsonData.badgeUrl;			
			
		}*/
		
		public function createSprite(dimensions:Rectangle = null):Sprite
		{
			return new Sprite();
		}		
		
		private static function dateFromString(str:String):Date
		{
			return new Date();
		}
		
		public function get title():String { return _title; }
		
		public function get numViews():int { return _numViews; }
		
		public function get numVotes():int { return _numVotes; }
		
		public function get numComments():int { return _numComments; }
		
		public function get numHearts():int { return _numHearts; }
		
		public function get rank():int { return _rank; }
		
		public function get dateCreated():Date { return _dateCreated; }
		
		public function get description():String { return _description; }
		
		public function get imageUrl():String { return _imageUrl; }
		
		public function get badgeUrl():String { return _badgeUrl; }
		
		
		public function get sprite():Sprite {  return _sp; }
	}
	
}